package ui;

import java.awt.Dimension;
import java.io.IOException;

import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

public class HelpScreen extends JPanel 
{
	private Dimension helpScreenSize = new Dimension(430, 284);
	private JDialog dialog;
	private JEditorPane htmlPane;
	private JScrollPane scrollPane;
	public HelpScreen() {
		dialog = new JDialog();
		//this.setSize(helpScreenSize);
		dialog.setSize(446,322);
		dialog.setAlwaysOnTop(true);
		
		dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		htmlPane = new JEditorPane();
	    htmlPane.setEditable(false);
		scrollPane = new JScrollPane(htmlPane);
		scrollPane.setSize(helpScreenSize);
		dialog.setContentPane(this);
		setLayout(null);
		this.add(scrollPane);
	}
	
	public void displayHelp() {
    java.net.URL helpURL =  HelpScreen.class.getResource("SEP APPLICATION.htm");
    if (helpURL != null) {
        try {
            htmlPane.setPage(helpURL);
        } catch (IOException e) {
            System.err.println("Attempted to read a bad URL: " + helpURL);
        }
    } else {
        System.err.println("Couldn't find file: TextSampleDemoHelp.html");
    }
    dialog.setVisible(true);
    scrollPane.setVisible(true);
    dialog.toFront();

	}
	public void setVisible(boolean b) {
		displayHelp();
	}
}
